1 package ch.odi.util.xml;
2
3 import java.util.Enumeration;
4
5 import org.w3c.dom.Node;
6 import org.w3c.dom.NodeList;
7
8 /***
9 * Iterates over a node list.
10 *
11 * @author oglueck
12 */
13 public class NodeEnumeration implements Enumeration {
14 private NodeList list;
15 private int position;
16
17 /***
18 * Creates an iterator over the specified NodeList.
19 */
20 public NodeEnumeration(NodeList list) {
21 this.list = list;
22 this.position = 0;
23 }
24
25
26
27
28 public boolean hasMoreElements() {
29 return (position < list.getLength());
30 }
31
32 /***
33 * Gets the next Node.
34 * @return a Node object.
35 */
36 public Object nextElement() {
37 Node item = list.item(position);
38 position++;
39 return item;
40 }
41
42 }